package com.lidongwei.eurekaconsumer.service;

import com.lidongwei.eurekaconsumer.client.DcClient;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ConsumerService {
    @Autowired
    DcClient dcClient;

    @HystrixCommand(fallbackMethod = "fallback")
    public String consumer() {
        try {
            Thread.sleep(5000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return dcClient.consumer();
    }

    public String fallback() {
        return "fallback";
    }
}
